/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebareportes;

import java.sql.*;


/**
 *
 * @author Emmanuel
 */
public class conectar {
    
    Connection miconexion;
    Statement stSentencias;
    ResultSet srDatos;
    PreparedStatement psPrepararSentencias;
    
    public conectar() throws SQLException, ClassNotFoundException
    {
    
        try {
            Class.forName("com:mysql.jdbc,Driver");
            
            String url="jdbc:mysql://localhost/regpeliculas";
            miconexion=DriverManager.getConnection(url, "root", "");
            
            stSentencias=miconexion.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
            
            
        } catch (ClassCastException ex) {
            
            throw ex;
            
        }catch(SQLException ex1)
        {
        
            throw ex1;
            
        }
    
    }
    
    
    public ResultSet consulta(String sql) throws SQLException
    {
    
        try {
            srDatos=stSentencias.executeQuery(sql);
        } catch (SQLException ex) {
            
            throw ex;
            
        }
        return srDatos;
        
        
    }
        
}
